package a.f.n;

import a.a.kb;
import a.c.a;
import a.c.ab;
import a.c.bb;
import a.c.d;
import a.c.e;
import a.c.m;
import a.c.x;
import a.d.s;
import a.f.c.c;
import a.f.*;
import a.f.o;

import java.awt.geom.Rectangle2D;
import java.util.Comparator;

import a.f.n.cb;
import a.d.s;

public class b
  extends mb
{
  public static final Object w = "y.layout.tree.ARTreeLayouter.RATIO";
  public static final Object x = "y.layout.tree.ARTreeLayouter.ROOT_PLACEMENT";
  public static final Object y = "y.layout.tree.ARTreeLayouter.PLACEMENT_TOP";
  public static final Object z = "y.layout.tree.ARTreeLayouter.PLACEMENT_CORNER";
  public static final Object A = "y.layout.tree.ARTreeLayouter.PLACEMENT_CORNER_SIDE";
  public static final Object B = "y.layout.tree.ARTreeLayouter.PLACEMENT_CORNER_TOP";
  public static final Object C = "y.layout.tree.ARTreeLayouter.ROUTING_POLICY";
  public static final Object D = "y.layout.tree.ARTreeLayouter.ROUTING_HORIZONTAL";
  public static final Object E = "y.layout.tree.ARTreeLayouter.ROUTING_VERTICAL";
  private x F;
  private cb G;
  protected o H;
  private double I = 10.0D;
  private double J = 10.0D;
  private double K = 5.0D;
  private double L = 1.41D;
  private Object M = z;
  private Object N = D;
  private double O = 20.0D;
  Comparator P;
  public static int Q;
  
  public b()
  {
    vc localvc = g();
    if ((k.n) || ((localvc instanceof c))) {
      ((c)localvc).a(false);
    }
  }
  
  public void a(double paramDouble)
  {
    this.I = paramDouble;
  }
  
  public double a()
  {
    return this.I;
  }
  
  public void b(double paramDouble)
  {
    this.J = paramDouble;
  }
  
  public double s()
  {
    return this.J;
  }
  
  public void a(o paramo)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    if (!bool2)
    {
      if (!kb.e(paramo)) {
        throw new a("Graph is not a tree");
      }
      wc.a(paramo);
      this.H = paramo;
    }
    ab localab = kb.i(paramo);
    this.G = new cb(paramo);
    e locale = this.G.a();
    this.F = paramo.B();
    b(locale);
    d(locale);
    paramo.a(this.F);
    do
    {
      if (localab.isEmpty()) {
        break;
      }
      d locald = localab.o();
      wc.a(paramo.b(locald));
      paramo.e(locald);
      if ((!bool2) && (bool1)) {
        return;
      }
    } while (!bool1);
    if (!bool2) {
      wc.b(paramo);
    }
  }
  
  public boolean b(o paramo)
  {
    return kb.e(paramo);
  }
  
  protected double a(e parame)
  {
    boolean bool = k.n;
    a.c.k localk = this.H.c(w);
    if (!bool) {
      if (localk == null) {
        return u();
      }
    }
    Object localObject = localk.get(parame);
    if ((bool) || ((localObject instanceof Number))) {
      return ((Number)localObject).doubleValue();
    }
    return u();
  }
  
  private a_ b(e parame)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    a_ locala_1 = new a_();
    this.F.a(parame, locala_1);
    if (!bool2)
    {
      if (!this.G.e(parame))
      {
        double d1 = 0.0D;
        double d2 = 0.0D;
        Object localObject1 = b(parame);
        Object localObject2 = a(parame);
        Object localObject3 = parame.q();
        do
        {
          if (!((a.c.w)localObject3).e()) {
            break;
          }
          e locale = ((a.c.w)localObject3).d();
          if (bool2) {
            break label778;
          }
          a_ locala_2 = b(locale);
          ((a.c.w)localObject3).f();
          if (bool1) {
            return locala_1;
          }
        } while (!bool1);
        localObject3 = null;
        localObject3 = a(parame, a(parame));
        if (!bool2)
        {
          if (!bool2)
          {
            if (y.equals(localObject1))
            {
              locala_1.c = (this.H.t(parame) + 2.0D * this.O + ((s)localObject3).c());
              locala_1.a = Math.max(this.H.s(parame), ((s)localObject3).b());
            }
          }
          else
          {
            if (bool2) {
              break label750;
            }
            if (!bool1) {
              break label737;
            }
          }
          double d3 = this.H.s(parame);
          double d4 = this.H.t(parame);
          double d5 = Math.max(d3, ((s)localObject3).b() + 2.0D * this.O) * (d4 + ((s)localObject3).c() + 2.0D * this.O);
          double d6 = (d3 + 2.0D * this.O + ((s)localObject3).b()) * Math.max(d4, ((s)localObject3).c() + 2.0D * this.O);
          double d8;
          if ((bool2) || ((locala_1.g > 1) || (D.equals(localObject2))))
          {
            d8 = 2.0D * this.O + ((s)localObject3).c();
            if (bool2) {
              break label384;
            }
            if (!bool1) {}
          }
          else
          {
            d8 = this.J + ((s)localObject3).c();
          }
          if (!bool2) {
            if (this.O < d3)
            {
              label384:
              d7 = Math.max(d3, ((s)localObject3).b() + 2.0D * this.O);
              if (bool2) {
                break label446;
              }
              if (!bool1) {
                break label438;
              }
            }
          }
          double d7 = Math.max(d3, ((s)localObject3).b() + this.O + d3);
          label438:
          label446:
          if (!bool2) {
            if (z.equals(localObject1))
            {
              if (!bool2)
              {
                if (d5 < d6)
                {
                  d8 += d4;
                  if (!bool2)
                  {
                    if (this.O < d3)
                    {
                      d7 = Math.max(d3, ((s)localObject3).b() + 2.0D * this.O);
                      if (bool2) {
                        break label731;
                      }
                      if (!bool1) {
                        break label725;
                      }
                    }
                    d7 = Math.max(d3, ((s)localObject3).b() + this.O + d3);
                    if (bool2) {
                      break label731;
                    }
                  }
                  if (!bool1) {
                    break label725;
                  }
                }
                locala_1.i = true;
                d8 = Math.max(d8, d4);
                d7 = d3 + ((s)localObject3).b() + 2.0D * this.O;
                if (bool2) {
                  break label731;
                }
              }
              if (!bool1) {
                break label725;
              }
            }
          }
          if (!bool2)
          {
            if (A.equals(localObject1))
            {
              locala_1.i = true;
              d8 = Math.max(d8, d4);
              d7 = d3 + ((s)localObject3).b() + 2.0D * this.O;
              if (bool2) {
                break label731;
              }
              if (!bool1) {
                break label725;
              }
            }
            d8 += d4;
            if (bool2) {}
          }
          else if (this.O < d3)
          {
            d7 = Math.max(d3, ((s)localObject3).b() + 2.0D * this.O);
            if (bool2) {
              break label731;
            }
            if (!bool1) {
              break label725;
            }
          }
          d7 = Math.max(d3, ((s)localObject3).b() + this.O + d3);
          label725:
          locala_1.a = d7;
          label731:
          locala_1.c = d8;
          label737:
          if (bool2) {
            break label778;
          }
          locala_1.f = ((s)localObject3);
          label750:
          if (!bool1) {}
        }
      }
      else
      {
        locala_1.a = this.H.s(parame);
      }
    }
    else {
      locala_1.c = this.H.t(parame);
    }
    label778:
    return locala_1;
  }
  
  private s a(e parame, double paramDouble)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    double d1 = this.I;
    double d2 = this.J;
    Object localObject1 = a(parame);
    Rectangle2D.Double[] arrayOfDouble = new Rectangle2D.Double[parame.e()];
    Rectangle2D.Double localDouble1 = new Rectangle2D.Double();
    int j = 0;
    a.c.w localw = new bb(c(parame)).l();
    e locale;
    a_ locala_;
    label193:
    Rectangle2D.Double localDouble2;
    if (!bool2) {
      if (D.equals(localObject1))
      {
        d2 += this.O;
        localObject2 = localw;
        do
        {
          if (!((a.c.w)localObject2).e()) {
            break;
          }
          locale = ((a.c.w)localObject2).d();
          locala_ = (a_)this.F.get(locale);
          if ((!bool2) && (bool1)) {
            break label193;
          }
          arrayOfDouble[(j++)] = new Rectangle2D.Double(0.0D, 0.0D, locala_.a + d1, locala_.c + d2);
          ((a.c.w)localObject2).f();
        } while (!bool1);
        if (!bool2)
        {
          i = wc.a(arrayOfDouble, localDouble1, paramDouble, 1);
          j = 0;
          localw.h();
          localObject2 = localw;
          do
          {
            if (!((a.c.w)localObject2).e()) {
              break;
            }
            locale = ((a.c.w)localObject2).d();
            locala_ = (a_)this.F.get(locale);
            localDouble2 = arrayOfDouble[(j++)];
            locala_.d = localDouble2.x;
            if (bool2) {
              break label563;
            }
            locala_.e = localDouble2.y;
            if (bool1) {
              break label560;
            }
            ((a.c.w)localObject2).f();
          } while (!bool1);
        }
      }
      else
      {
        d1 += this.O;
      }
    }
    Object localObject2 = localw;
    do
    {
      if (!((a.c.w)localObject2).e()) {
        break;
      }
      locale = ((a.c.w)localObject2).d();
      locala_ = (a_)this.F.get(locale);
      if ((!bool2) && (bool1)) {
        break label408;
      }
      arrayOfDouble[(j++)] = new Rectangle2D.Double(0.0D, 0.0D, locala_.c + d2, locala_.a + d1);
      ((a.c.w)localObject2).f();
    } while (!bool1);
    label408:
    int i = wc.a(arrayOfDouble, localDouble1, 1.0D / paramDouble, 1);
    localDouble1.setFrame(localDouble1.getY(), localDouble1.getX(), localDouble1.getHeight(), localDouble1.getWidth());
    j = 0;
    localw.h();
    localObject2 = localw;
    do
    {
      if (!((a.c.w)localObject2).e()) {
        break;
      }
      locale = ((a.c.w)localObject2).d();
      locala_ = (a_)this.F.get(locale);
      localDouble2 = arrayOfDouble[(j++)];
      locala_.d = localDouble2.y;
      if (bool2) {
        break label563;
      }
      locala_.e = localDouble2.x;
      if (bool1) {
        break label560;
      }
      ((a.c.w)localObject2).f();
    } while (!bool1);
    if (!bool2) {}
    label560:
    label563:
    localObject2 = (a_)this.F.get(parame);
    ((a_)localObject2).g = i;
    return new s(localDouble1.getWidth() - localDouble1.getX() - d1, localDouble1.getHeight() - localDouble1.getY() - d2);
  }
  
  protected a.c.w c(e parame)
  {
    if (this.P != null) {
      parame.b(this.P);
    }
    return parame.q();
  }
  
  public Comparator t()
  {
    return this.P;
  }
  
  public void a(Comparator paramComparator)
  {
    this.P = paramComparator;
  }
  
  private void d(e parame)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    a_ locala_1 = (a_)this.F.get(parame);
    Object localObject1 = b(parame);
    Object localObject2 = a(parame);
    double d2;
    if (y.equals(localObject1))
    {
      d2 = this.H.q(parame) + this.H.t(parame) + 2.0D * this.O;
      if (bool2) {
        break label115;
      }
      d1 = this.H.m(parame) - locala_1.f.b() / 2.0D;
      if (!bool1) {
        break label377;
      }
    }
    label115:
    double d3 = this.H.s(parame);
    if (!bool2) {
      if (locala_1.i)
      {
        if ((bool2) || ((locala_1.g > 1) || (D.equals(localObject2))))
        {
          if (bool2) {
            break label195;
          }
          d2 = this.H.q(parame) + 2.0D * this.O;
          if (!bool1) {
            break label197;
          }
        }
        label195:
        d2 = this.H.q(parame) + this.J;
        label197:
        d1 = this.H.p(parame) + d3 + 2.0D * this.O;
        if ((!bool2) && (!bool1)) {
          break label377;
        }
      }
    }
    if ((bool2) || ((locala_1.g > 1) || (D.equals(localObject2))))
    {
      d2 = this.H.q(parame) + this.H.t(parame) + 2.0D * this.O;
      if (bool2) {
        break label327;
      }
      if (!bool1) {}
    }
    else
    {
      d2 = this.H.q(parame) + this.H.t(parame) + this.J;
    }
    if (!bool2) {
      if (this.O < d3)
      {
        label327:
        if (bool2) {
          break label375;
        }
        d1 = this.H.p(parame) + 2.0D * this.O;
        if (!bool1) {
          break label377;
        }
      }
    }
    label375:
    double d1 = this.H.p(parame) + this.O + d3;
    label377:
    m localm = parame.n();
    do
    {
      if (!localm.e()) {
        break;
      }
      d locald = localm.a();
      e locale = locald.f();
      a_ locala_2 = (a_)this.F.get(locale);
      this.H.c(locale, d1 + locala_2.d, d2 + locala_2.e);
      if (!bool2) {
        if (!this.G.e(locale)) {
          d(locale);
        }
      }
      zb localzb = this.H.b(locald);
      localzb.b();
      a(localzb, parame, locale, localObject1, localObject2);
      localm.f();
    } while (!bool1);
  }
  
  protected void a(zb paramzb, e parame1, e parame2, Object paramObject1, Object paramObject2)
  {
    boolean bool2 = k.n;
    boolean bool1 = k.m;
    a_ locala_ = (a_)this.F.get(parame1);
    double d1 = this.H.s(parame1);
    double d2 = this.H.t(parame1);
    double d3;
    double d4;
    double d5;
    if (!bool2) {
      if (y.equals(paramObject1))
      {
        d3 = this.H.m(parame1);
        d4 = this.H.q(parame1) + d2 + this.O;
        paramzb.a(d3, d4);
        if (!bool2) {
          if (D.equals(paramObject2))
          {
            d5 = this.H.q(parame2) - this.O;
            paramzb.a(d3, d5);
            paramzb.a(this.H.m(parame2), d5);
            if (!bool2) {
              if (!bool1) {
                return;
              }
            }
          }
          else
          {
            if (bool2) {
              break label231;
            }
          }
        }
        if (this.H.m(parame2) < d3)
        {
          d5 = this.H.p(parame2) + this.H.s(parame2) + this.O;
          if (bool2) {
            break label262;
          }
          if (!bool1) {}
        }
        else
        {
          label231:
          d5 = this.H.p(parame2) - this.O;
        }
        paramzb.a(d5, d4);
        paramzb.a(d5, this.H.n(parame2));
        label262:
        if ((!bool2) && (!bool1)) {
          return;
        }
      }
    }
    if (locala_.i)
    {
      paramzb.a(new a.d.w(0.0D, -d2 / 2.0D + this.K));
      d3 = this.H.p(parame1) + d1 + this.O;
      d4 = this.H.q(parame1) + this.K;
      if (bool2) {
        break label424;
      }
      if (!bool1) {}
    }
    else
    {
      paramzb.a(new a.d.w(-d1 / 2.0D + this.K, 0.0D));
      d3 = this.H.p(parame1) + this.K;
      d4 = this.H.q(parame1) + d2 + this.O;
    }
    paramzb.a(d3, d4);
    if (D.equals(paramObject2))
    {
      label424:
      d5 = this.H.q(parame2) - this.O;
      paramzb.a(d3, d5);
      paramzb.a(this.H.m(parame2), d5);
      if (!bool2) {
        if (!bool1) {
          return;
        }
      }
    }
    else
    {
      d5 = this.H.p(parame2) - this.O;
      paramzb.a(d5, d4);
    }
    paramzb.a(d5, this.H.n(parame2));
  }
  
  protected Object a(Object paramObject)
  {
    boolean bool = k.n;
    a.c.k localk = this.H.c(C);
    if (!bool) {
      if (localk == null) {
        return w();
      }
    }
    Object localObject = localk.get(paramObject);
    if (!bool) {
      if (localObject != null) {
        return localObject;
      }
    }
    return w();
  }
  
  protected Object b(Object paramObject)
  {
    boolean bool = k.n;
    a.c.k localk = this.H.c(x);
    if (!bool) {
      if (localk == null) {
        return v();
      }
    }
    Object localObject = localk.get(paramObject);
    if (!bool) {
      if (localObject != null) {
        return localObject;
      }
    }
    return v();
  }
  
  public double u()
  {
    return this.L;
  }
  
  public void c(double paramDouble)
  {
    this.L = paramDouble;
  }
  
  public Object v()
  {
    return this.M;
  }
  
  public void c(Object paramObject)
  {
    this.M = paramObject;
  }
  
  public Object w()
  {
    return this.N;
  }
  
  public void d(Object paramObject)
  {
    this.N = paramObject;
  }
  
  public double x()
  {
    return this.O;
  }
  
  public void d(double paramDouble)
  {
    this.O = paramDouble;
  }
  
  static final class a_
  {
    double a;
    double c;
    double d;
    double e;
    s f;
    int g;
    boolean i;
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.n.b

 * JD-Core Version:    0.7.0.1

 */